package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AlertDataHandleDto;
import com.zzyl.dto.AlertDataPageQueryDto;
import com.zzyl.service.AlertDataService;
import com.zzyl.vo.AlertDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.zzyl.base.ResponseResult.success;

@RestController
@RequestMapping("/alert-data")
@Api(tags = "管理端 - 报警数据相关接口")
public class AlertDataController {

    @Autowired
    private AlertDataService alertDataService;

    /**
     * 分页查询报警数据
     * @param alertDataPageQueryDto
     * @return
     */
    @GetMapping("/pageQuery")
    @ApiOperation("分页查询报警数据")
    public ResponseResult<PageResponse<AlertDataVo>> pageQuery(
          /*@ApiParam(value = "页码", required = true) @RequestParam("pageNum") Integer pageNum,
          @ApiParam(value = "页面大小", required = true) @RequestParam("pageSize") Integer pageSize,
          @ApiParam(value = "设备名称(精确搜索)") @RequestParam(value = "deviceName", required = false) String deviceName,
          @ApiParam(value = "报警数据id") @RequestParam(value = "id", required = false) Long id,
          @ApiParam(value = "开始报警时间") @RequestParam(value = "startTime", required = false) Long startTime,
          @ApiParam(value = "结束报警时间") @RequestParam(value = "endTime", required = false) Long endTime,
          @ApiParam(value = "状态，0：待处理，1：已处理") @RequestParam(value = "status", required = false) Integer status*/
            AlertDataPageQueryDto alertDataPageQueryDto
    ){
        PageResponse<AlertDataVo> pageResponse = alertDataService.pageQuery(alertDataPageQueryDto);
        return success(pageResponse);
    }

    /**
     * 处理设备报警数据
     * @param id
     * @param alertDataHandleDto
     * @return
     */
    @PutMapping("/handleAlertData/{id}")
    @ApiOperation("处理设备报警数据")
    public ResponseResult handleAlertData(@PathVariable Long id, @RequestBody AlertDataHandleDto alertDataHandleDto){
        alertDataService.handleAlertData(id, alertDataHandleDto);
        return success();
    }
}
